package com.dux.shiro1.web.error;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Title: ErrorHandler <br>
 * Description: ErrorHandler <br>
 * Date: 2018年10月22日
 *
 * @author 王东旭
 * @version 1.0.0
 * @since jdk8
 */

@RestControllerAdvice
public class ErrorHandler {

    private static final Logger LOG = LoggerFactory.getLogger(ErrorHandler.class);

    @ExceptionHandler(Exception.class)
    public ResponseEntity<RBody> exception(Exception e){
        LOG.error("请求异常",e);
        return ResponseEntity.status(CodeEnum.SYSTEM_ERROR.getStatus()).body(RBody.error());
    }
}
